package com.mxpio.erp.equipment.controller;

import com.mxpio.erp.common.equipment.entity.EquipmentUpkeepPlanDetailParam;
import com.mxpio.erp.common.equipment.service.EquipmentUpkeepPlanDetailParamService;
import com.mxpioframework.common.vo.Result;
import com.mxpioframework.jpa.query.Criteria;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.UnsupportedEncodingException;


@Tag(name = "EquipmentUpkeepPlanDetailParamController}", description = "保养计划明细选项")
@RestController
@RequestMapping("/erp/equipment/upkeep/plan/detail/param/")
public class EquipmentUpkeepPlanDetailParamController {

    @Autowired
    private EquipmentUpkeepPlanDetailParamService equipmentUpkeepPlanDetailParamService;

    @GetMapping("page")
    @Operation(summary = "保养计划明细选项列表", description = "获取保养计划明细选项列表（分页）", method = "GET")
    public Result<Page<EquipmentUpkeepPlanDetailParam>> page(@Parameter(description="查询参数") Criteria criteria, @Parameter(description="每页条数")Integer pageSize, @Parameter(description="页号")Integer pageNo) throws UnsupportedEncodingException {
        Pageable page = PageRequest.of(pageNo-1, pageSize);
        Page<EquipmentUpkeepPlanDetailParam> pageResult = equipmentUpkeepPlanDetailParamService.listPage(EquipmentUpkeepPlanDetailParam.class, page, criteria);
        return Result.OK(pageResult);
    }

}
